<?xml version="1.0" encoding="utf-8"?>
<!-- transform.xslt -->
<!-- Joshua Marshall Moore, 2011 -->

<!-- Thanks http://www.dpawson.co.uk/xsl/sect2/N2193.html#d3680e19 for explaining how
    to perform a depth first traversal -->
<!-- Thanks http://www.biglist.com/lists/xsl-list/archives/200206/msg00125.html for
    explaining how to repeat a character--> 
<!-- http://stackoverflow.com/questions/723226/producing-a-new-line-in-xslt -->
 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output 
        method="text" 
        indent="yes" 
        encoding="utf-8" 
        omit-xml-declaration="yes"
    />
    
    <xsl:template match="/">
            <xsl:apply-templates select="map/node">
                <xsl:with-param name="depth" select="0" />
            </xsl:apply-templates>
    </xsl:template>

    <!-- applies to regular nodes  -->
    <xsl:template match="node">
        <xsl:param name="depth" />

        <xsl:value-of select="@TEXT"/><xsl:text>&#10;</xsl:text>
        
        <xsl:apply-templates select="node">
            <xsl:with-param name="depth" select="$depth + 1" />
        </xsl:apply-templates>
    </xsl:template>

</xsl:stylesheet>